import { request } from '@@/exports';
import { Room } from 'livekit-client';

/**
 * 创建token
 */
export const createToken = (
  server: string,
  name: string,
  identity: string,
  room: string,
) => {
  return request<{ success: boolean; data: string }>(
    `${server}/live/createToken`,
    {
      params: { name, identity, room },
    },
  );
};

/**
 * 创建房间
 */
export const createRoom = (server: string, name: string, metadata: string) => {
  return request<{ success: boolean; data: Room }>(
    `${server}/live/createRoom`,
    {
      params: { name, metadata },
    },
  );
};

/**
 * 创建房间
 */
export const deleteRoom = (server: string, name: string) => {
  return request<{ success: boolean; data: Room }>(
    `${server}/live/createRoom`,
    {
      params: { name },
    },
  );
};

/**
 * 获取房间
 */
export const listRooms = (server: string) => {
  return request<{ success: boolean; data: Room[] }>(
    `${server}/live/listRooms`,
  );
};
